package com.yhb.base.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

/**
 * Created by yanghongbo on 2020/3/5.
 */
public class AnnotationTest {

    @_2_annotation(value = "张三", age = 20)
    public void aa(String param1,Integer param2) {

    }

    public static void main(String[] args) {

        try {
            Method method = AnnotationTest.class.getDeclaredMethod("aa",String.class,Integer.class);
            if (method != null) {
                Annotation[] annotations = method.getAnnotations();
                for (int i = 0; i < annotations.length; i++) {
                    if (annotations[i] instanceof _2_annotation) {
                        System.out.println(((_2_annotation) annotations[i]).value() + "_" + ((_2_annotation) annotations[i]).age());
                    }
                }
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
}
